package com.ler.yrmall.basic;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.Version;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;

/**
 * @author Leron
 * @version 1.0
 * JsonIgnore 标注的字段如果需要返回给前端直接在子类中添加字段不添加此标注即可
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class BaseEntity<T extends BaseEntity<?>> extends BaseAssignKey<T> {

    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @JsonIgnore
    @TableField(fill = FieldFill.UPDATE)
    private LocalDateTime updateTime;

    @JsonIgnore
    @TableField(fill = FieldFill.INSERT)
    private String createBy;

    @JsonIgnore
    @TableField(fill = FieldFill.UPDATE)
    private String updateBy;

    @Version
    @JsonIgnore
    private Integer version;

    @TableLogic
    @JsonIgnore
    private Integer isDeleted;

}
